<template>
  <!-- 基本信息-->
  <div class="bg-white my-[10px]">
    <BaseHead style="border-bottom: 0">基本信息</BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">合同编号</td>
        <td colspan="3">{{ detailData.code ? detailData.code : "审核通过后生成" }}</td>
      </tr>
      <tr>
        <td class="td-name">合同名称</td>
        <td>{{ detailData.name }}</td>
        <td class="td-name">负责人类型</td>
        <td><CommonLabel :dataList="memberTypeList" :value="detailData.chargerType" /></td>
      </tr>
      <tr>
        <td class="td-name">负责人</td>
        <td>{{ detailData.chargerName }}</td>
        <td class="td-name">负责人电话</td>
        <td>{{ detailData.chargerPhone }}</td>
      </tr>
      <tr>
        <td class="td-name">负责人邮箱</td>
        <td>{{ detailData.chargerEmail }}</td>
        <td class="td-name">所属单位</td>
        <td>
          <CommonTreeLabel
            :dataList="unitList"
            :value="detailData.unitId"
            valueKey="codeColumn"
            labelKey="valueColumn"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">经办人</td>
        <td>{{ detailData.transactor }}</td>
        <td class="td-name">经办人电话</td>
        <td>{{ detailData.transactorPhone }}</td>
      </tr>
      <tr>
        <td class="td-name">合同经费</td>
        <td>{{ detailData.feeAuthorize }} 万元</td>
        <td class="td-name">合同类别</td>
        <td>
          <CommonTreeLabel :dataList="contractTypeList" :value="detailData.contractType"   labelKey="labelLocal"/>
        </td>
      </tr>
      <tr>
        <td class="td-name">签订日期</td>
        <td>{{ detailData.authorizeDate }}</td>
        <td class="td-name">开始日期</td>
        <td>{{ detailData.beginDate }}</td>
      </tr>
      <tr>
        <td class="td-name">终止日期</td>
        <td>{{ detailData.planEndDate }}</td>
        <td class="td-name">合同有效状态</td>
        <td>
          <CommonLabel :dataList="contractEffectiveTypeList" :value="detailData.validState" />
        </td>
      </tr>
      <tr>
        <td class="td-name">进行状态</td>
        <td>
          <CommonLabel :dataList="contractPerformTypeList" :value="detailData.projectStatusId" />
        </td>
        <td class="td-name">支付方式</td>
        <td>
          <CommonLabel :dataList="payTypeList" :value="detailData.payWay" />
        </td>
      </tr>
      <tr>
        <td class="td-name">甲方是否盖章</td>
        <td>{{ detailData.buyerIsSeal }}</td>
        <td class="td-name">乙方是否盖章</td>
        <td>{{ detailData.yfIsSeal }}</td>
      </tr>
      <tr>
        <td class="td-name">合同是否回收</td>
        <td colspan="3">{{ detailData.isRecover }}</td>
      </tr>
      <tr>
        <td class="td-name">盖章页电子版</td>
        <td colspan="3">
          <template v-if="detailData.signatureList">
            <p v-for="item in detailData.signatureList" :key="item.id" class="my-[5px]">
              {{ item.name }}
            </p>
          </template>
        </td>
      </tr>
    </BaseTable>
  </div>
  <div class="bg-white my-[10px]">
    <BaseHead style="border-bottom: 0">甲方信息</BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">甲方名称</td>
        <td>{{ detailData.buyerName }}</td>
        <td class="td-name">甲方类型</td>
        <td><CommonLabel :dataList="jfTypeList" :value="detailData.buyerType" /></td>
      </tr>
      <tr>
        <td class="td-name">甲方联系人</td>
        <td>{{ detailData.buyerChargerName }}</td>
        <td class="td-name">甲方联系人电话</td>
        <td>
          {{ detailData.buyerTel }}
        </td>
      </tr>
      <tr>
        <td class="td-name">甲方所属省份</td>
        <td>
          <CommonLabel
            :dataList="provinceList"
            labelKey="valueColumn"
            valueKey="codeColumn"
            :value="detailData.buyerArea"
          />
        </td>
        <td class="td-name">甲方所属地市</td>
        <td>
          <CommonLabel
            :dataList="cityList.value"
            labelKey="label"
            valueKey="id"
            :value="detailData.buyerCity"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">甲方地址</td>
        <td>{{ detailData.buyerAddress }}</td>
        <td class="td-name">甲方邮编</td>
        <td>{{ detailData.buyerZipcode }}</td>
      </tr>
      <tr>
        <td class="td-name">备注</td>
        <td colspan="3">{{ detailData.note }}</td>
      </tr>
    </BaseTable>
  </div>
  <!-- 教育部统计信息 -->
  <div class="bg-white">
    <BaseHead style="border-bottom: 0">教育部统计信息 </BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">统计归属</td>
        <td><CommonLabel :dataList="tjgsList" :value="detailData.subjectClassId" /></td>
        <td class="td-name">一级学科</td>
        <td>
          <CommonLabel
            :dataList="subjectList.value"
            :value="detailData.subjectId"
            labelKey="label"
            valueKey="id"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">社会经济服务目标</td>
        <td><CommonTreeLabel :dataList="jjfwmbList" :value="detailData.societyTarget" /></td>
        <td class="td-name">项目来源</td>
        <td>
          <CommonLabel
            :dataList="projectSourceList.value"
            :value="detailData.projectSourceId"
            labelKey="label"
            valueKey="id"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">研究类别</td>
        <td>
          <CommonLabel
            :dataList="researchTypeList.value"
            :value="detailData.researchClassId"
            labelKey="label"
            valueKey="id"
          />
        </td>
        <td class="td-name">合作形式</td>
        <td>
          <CommonLabel :dataList="hzTypeList" :value="detailData.cooperateId" />
        </td>
      </tr>
      <tr>
        <td class="td-name">国民经济行业</td>
        <td>
          <CommonTreeLabel :dataList="gmjjhyList" :value="detailData.gmjjhy" />
        </td>
      </tr>
    </BaseTable>
  </div>
</template>

<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
import BaseTable from "@/views/project/components/BaseTable.vue";
import CommonLabel from "@/views/project/components/CommonLabel.vue";
import CommonTreeLabel from "@/views/project/components/CommonTreeLabel.vue";
import { baseDetail } from "@/api/project/zx/lxxm";
import useCommonFetch from "@/hooks/useCommonFetch";
const memberTypeList = inject("memberTypeList");
const unitList = inject("unitList");
const contractTypeList = inject("contractTypeList");
const contractEffectiveTypeList = inject("contractEffectiveTypeList");
const contractPerformTypeList = inject("contractPerformTypeList");
const payTypeList = inject("payTypeList");
const jfTypeList = inject("jfTypeList");
const provinceList = inject("provinceList");
const tjgsList = inject("tjgsList");
const jjfwmbList = inject("jjfwmbList");
const hzTypeList = inject("hzTypeList");
const gmjjhyList = inject("gmjjhyList");
let subjectList = ref([]); //一级学科下拉数据
let researchTypeList = ref([]); //研究类别下拉数据
let projectSourceList = ref([]); //项目来源下拉数据
let cityList = ref([]);
const operateId = inject("id");
const detailData = ref({});
//获取数据详情
const getDetail = async () => {
  try {
    const res = await baseDetail(operateId.value);
    detailData.value = res.data;
    subjectList.value = useCommonFetch("一级学科", detailData.value.subjectClassId);
    researchTypeList.value = useCommonFetch("研究类别", detailData.value.subjectClassId);
    projectSourceList.value = useCommonFetch("项目来源", detailData.value.subjectClassId);
    cityList.value = useCommonFetch("甲方所属地市", detailData.value.buyerArea);
  } catch (error) {
    console.log(error);
  }
};
onMounted(() => {
  getDetail();
});
</script>

<style scoped lang="scss"></style>
